package com.shensi.adminCollect.controller.market;

import com.shensi.common.core.controller.BaseController;
import com.shensi.common.core.domain.AjaxResult;
import com.shensi.common.core.page.TableDataInfo;
import com.shensi.adminCollect.common.utils.poi.ExcelUtil;
import com.shensi.adminCollect.domain.markert.ReductionStationRelations;
import com.shensi.adminCollect.service.markert.IReductionStationRelationsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 立减活动和油站关系Controller
 * 
 * @author qujia
 * @date 2021-11-02
 */
@RestController
@RequestMapping("/market/reductionStationRelations")
public class ReductionStationRelationsController extends BaseController
{
    @Autowired
    private IReductionStationRelationsService reductionStationRelationsService;

    /**
     * 查询立减活动和油站关系列表
     */
    @PreAuthorize("@ss.hasPermi('market:reductionStationRelations:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReductionStationRelations reductionStationRelations)
    {
        startPage();
        List<ReductionStationRelations> list = reductionStationRelationsService.selectReductionStationRelationsList(reductionStationRelations);
        return getDataTable(list);
    }

    /**
     * 导出立减活动和油站关系列表
     */
    @PreAuthorize("@ss.hasPermi('market:reductionStationRelations:export')")
    @GetMapping("/export")
    public AjaxResult export(ReductionStationRelations reductionStationRelations)
    {
        List<ReductionStationRelations> list = reductionStationRelationsService.selectReductionStationRelationsList(reductionStationRelations);
        ExcelUtil<ReductionStationRelations> util = new ExcelUtil<ReductionStationRelations>(ReductionStationRelations.class);
        return util.exportExcel(list, "reductionStationRelations");
    }

    /**
     * 获取立减活动和油站关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('market:reductionStationRelations:query')")
    @GetMapping(value = "/{activityOilId}")
    public AjaxResult getInfo(@PathVariable("activityOilId") Long activityOilId)
    {
        return AjaxResult.success(reductionStationRelationsService.selectReductionStationRelationsById(activityOilId));
    }

    /**
     * 新增立减活动和油站关系
     */
    @PreAuthorize("@ss.hasPermi('market:reductionStationRelations:add')")
    @PostMapping
    public AjaxResult add(@RequestBody ReductionStationRelations reductionStationRelations)
    {
        return toAjax(reductionStationRelationsService.insertReductionStationRelations(reductionStationRelations));
    }

    /**
     * 修改立减活动和油站关系
     */
    @PreAuthorize("@ss.hasPermi('market:reductionStationRelations:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody ReductionStationRelations reductionStationRelations)
    {
        return toAjax(reductionStationRelationsService.updateReductionStationRelations(reductionStationRelations));
    }

    /**
     * 删除立减活动和油站关系
     */
    @PreAuthorize("@ss.hasPermi('market:reductionStationRelations:remove')")
    @DeleteMapping("/{activityOilIds}")
    public AjaxResult remove(@PathVariable Long[] activityOilIds)
    {
        return toAjax(reductionStationRelationsService.deleteReductionStationRelationsByIds(activityOilIds));
    }
}
